package Domain;

import Technical.Database;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;

public class PostBean implements Serializable{
    private String text;
    private Date date;
    private UserBean author;
    private ArrayList <CommentBean> comments = new ArrayList();
    private String header;
	private int postId;
    private Database db = new Database();
    
    public Iterator getAllComments(){
        return comments.iterator();
    }
    public void addComment(CommentBean c){
        comments.add(c);
        db.addNewComment(this, c);
    }
    
    public void setAuthor(UserBean author) {
        this.author = author;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public void setHeader(String header) {
        this.header = header;
    }

    public void setText(String text) {
        this.text = text;
    }
	
	public void setpostId(int postId){
		this.postId = postId;
	}
	
	public int getpostId(){
		return postId;
	}

    public UserBean getAuthor() {
        return author;
    }
    public Date getDate() {
        return date;
    }

    public String getHeader() {
        return header;
    }

    public String getText() {
        return text;
    }
	
	public void setCommentList(ArrayList list){
		this.comments = list;
	}
	
	public int getCommentCount(){
		Database db = new Database();
		return db.countComments(this);
	}
}
